__author__ = 'Douglas'


class ErrorCalculation:
    def __init__(self):
        self.global_error = 0.0
        self.set_size = 0.0

    def calculate_rms(self):
        return (self.global_error / self.set_size) ** 0.5

    def reset(self):
        self.__init__()

    def update_error(self, actual, ideal):
        self.global_error += sum([(a - i) ** 2 for a, i in zip(actual, ideal)])
        self.set_size += len(ideal)